from fastapi import APIRouter, Depends, Request
from module_admin.service.login_service import LoginService
from module_admin.entity.vo.employee_payment_vo import EmployeePaymentModel, EmployeePaymentQueryModel
from typing import List
from sqlalchemy.ext.asyncio import AsyncSession
from config.get_db import get_db
from module_admin.service.employee_payment_service import EmployeePaymentService
from utils.response_util import ResponseUtil
from utils.log_util import logger

# 员工支出管理 -路由-实现
employeePaymentController = APIRouter(prefix='/system/employee_payment', dependencies=[Depends(LoginService.get_current_user)])

@employeePaymentController.get('/list', response_model=List[EmployeePaymentModel])
async def get_employee_payment_list(
    request: Request,
    payment_query: EmployeePaymentQueryModel = Depends(EmployeePaymentQueryModel.as_query),
    query_db: AsyncSession = Depends(get_db),
):
    logger.info(f"Received payment query: {payment_query}")
    payment_query_result = await EmployeePaymentService.get_payment_list_services(query_db, payment_query, is_page=True)
    logger.info(f"Query result: {payment_query_result}")
    return ResponseUtil.success(data={"rows": payment_query_result}) 